/**
 * 简化数组项
 * @param {Array<any>} array
 * @param {Function} fn 简化方法
 * @param {String} childrenProp 子数据属性名
 */
export function simplifyArray (array, fn, childrenProp = 'children') {
  return array.map((t) => {
    const children = t[childrenProp]
    const result = fn(t)
    if (Array.isArray(children) && children.length !== 0) {
      result.children = simplifyArray(children, fn, childrenProp)
    }
    return result
  })
}
